﻿using System;
using System.Collections.Generic;
using System.Text;
using Kiiro.Common.Entities;
using Kiiro.Common.Utility;
using Kiiro.Validation.Interfaces;

namespace Kiiro.Validation.Validators.Entities
{
    public class ActivityHistoryValidator : BaseEntityValidator, IValidator<ActivityHistory>
    {
        private readonly List<ValidationMessage> validationErrors = new List<ValidationMessage> ( );

        #region  IValidator<ActivityHistory> Members
        public List<ValidationMessage> Validate ( ActivityHistory entityToValidate )
        {
            // If the entity is marked as deleted, don't do any validation, just return.
            if ( entityToValidate.EditType != EditType.Deleted )
            {
                ValidationMessage message = null;
                
                #region Required Fields Checks

                message = IsRequired ( entityToValidate.ActivityReferenceUrl, "Activity Reference  Url" );

                if ( message != null )
                {
                    entityToValidate.ActivityReferenceUrlMessage.Add ( message );
                    validationErrors.Add ( message );
                }

                message = IsRequired ( entityToValidate.ActivityItemType.ToString(), "Activity Item Type" );

                if ( message != null )
                {
                    entityToValidate.ActivityItemTypeMessage.Add ( message );
                    validationErrors.Add ( message );
                }

                message = IsRequired ( entityToValidate.EventType.ToString(), "Event Type" );

                if ( message != null )
                {
                    entityToValidate.EventTypeMessage.Add ( message );
                    validationErrors.Add ( message );
                }



                #endregion
            }

            return validationErrors;
        }
        #endregion
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.Validation/Validators/Entities/ActivityHistoryValidator.cs $
 * 
 * 3     17/08/09 10:45a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/